program C;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

var
  f, g: TextFile;
  E, R, N, answer: Int64;
  V: Array[1..10000] of Int64;
  t: Word;
  maxi: Int64;
  maxx: Int64;


procedure ReadData;
var
  i: Word;
begin
  Readln(f, e, r, n);
  MaxX := 0;
  for i := 1 to n do begin
    Read(f, v[i]);
    if (v[i] > MaxX) then begin
      MaxX := v[i];
      MaxI := i;
    end;
  end;
  Readln(f);
end;

procedure ProcessData;
var
  i: Word;
begin
  answer := 0;
  if R >= E then
    for i := 1 to n do
      answer := answer + v[i] * E
  else
    for i := 1 to n do
      if i = MaxI then
        answer := answer + v[i] * E
      else
        answer := answer + v[i] * R
end;


procedure OutputVerdict(casenum: Word);
begin
  writeln(g, 'Case #', casenum, ': ', answer);
end;


var
  i: Word;
  s: String;
begin
  try
    s := ParamStr(1);
    if (s = '') then
       s := 'input.txt';
    AssignFile(f, s);
    Reset(f);
    AssignFile(g, 'output.txt');
    Rewrite(g);
    try
      Readln(f, t);
      for i := 1 to t do begin
        ReadData;
        ProcessData;
        OutputVerdict(i);
      end;
    finally
      CloseFile(f);
      CloseFile(g);
    end;
    writeln('Reading finished');
    Readln;
    { TODO -oUser -cConsole Main : Insert code here }
  except
    on E: Exception do begin
      Writeln(E.ClassName, ': ', E.Message);
      readln;
    end;
  end;
end.
